/* 
 * jxListFiles Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * GPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxListFiles.view;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.SwingConstants;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxListFiles
 * @package org.jxListFiles.view
 * @date 18/04/2014 - 18:14:15
 */
public abstract class VwTypeFilter extends JDialog {
	
	private static final long serialVersionUID = 4298815287204155340L;
	
	private TypeFilterPanel panel;
	
	private JButton btnProcurar;
	
	private JButton btnCancelar;
	
	/**
	 * 
	 */
	public VwTypeFilter() {
	
		initGUI();
	}
	
	private void initGUI() {
	
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		getContentPane().setLayout(null);
		setSize(500, 375);
		
		getContentPane().add(getPanel());
		
		setLocationRelativeTo(null);
		setVisible(true);
		getContentPane().add(getBtnCancelar());
		getContentPane().add(getBtnProcurar());
	}
	
	public TypeFilterPanel getPanel() {
	
		if(panel == null) {
			panel = new TypeFilterPanel();
			panel.setLocation(0, 0);
		}
		return panel;
	}
	
	public JButton getBtnCancelar() {
	
		if(btnCancelar == null) {
			// TODO: Implementar Internacionalização
			btnCancelar = new JButton("Cancelar");
			btnCancelar.setIcon(new ImageIcon(VwTypeFilter.class.getResource("/org/jxSwing/resources/icon/action/clear-32x32.png")));
			btnCancelar.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnCancelar.setBounds(185, 305, 150, 40);
			btnCancelar.addActionListener(new ActionListener() {
				
				public void actionPerformed(ActionEvent actionEvent) {
				
					getPanel().clear();
					dispose();
				}
			});
		}
		return btnCancelar;
	}
	
	public JButton getBtnProcurar() {
	
		if(btnProcurar == null) {
			// TODO: Implementar Internacionalização
			btnProcurar = new JButton("Procurar");
			btnProcurar.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnProcurar.setIcon(new ImageIcon(VwTypeFilter.class.getResource("/org/jxSwing/resources/icon/action/find-32x32.png")));
			btnProcurar.setBounds(340, 305, 150, 40);
			btnProcurar.addActionListener(new ActionListener() {
				
				public void actionPerformed(ActionEvent actionEvent) {
				
					find();
					dispose();
				}
			});
		}
		return btnProcurar;
	}

	public List<String> getExtensions() {
	
		return getPanel().getExtensions();
	}
	
	/**
	 * 
	 */
	public abstract void find();
}
